<%@include file="../../../fragments/_taglibs.jsp" %>
<%@include file="../../../fragments/_message.jsp" %>
<script type="text/javascript">
    var findSec = function() {
        var form = $('#forms').val();
        //alert(form);
        if (form !== null && form !== undefined && form !== '') {
            var url = './wizard/' + form + '/findSec/ #updateme';
            $('#updateme').load(url, function(responseText, textStatus, XMLHttpRequest) {
                
            });
        
        }
        else{
            $('#updateme').html("Debe seleccionar un Formulario");
        }
        
    };
  
   var SubmitForm=function(){
        var form=$('#forms').val();
        var section=$('#formsSections').val();
        var vertion=$('#formsVertion').val();
        
        if (form !== null && form !== undefined && form !== '' 
                && section !== null && section !== undefined && section !== '' 
                && vertion !== null && vertion !== undefined && vertion !== '' ){
            document.fselection.submit();
        }
        else
            {
               alert("Debe seleccionar \n* Formulario \n* Seccion \n* Version");
            }
   }

</script>

<style>
    .selected_field{
        
    }
</style>
<center>
<fieldset>
    
    <legend style=" font-family: verdana; font-weight: bold">Construccion de formularios de captura</legend>

    <H1>FORMULARIOS</H1>
        <form:form name="fselection" modelAttribute="wizardFormController" method="post" action="./wizard/construir/" >    
         
            <form:select cssClass="select_field" id="forms" path="formselected.cformulario" onchange="findSec()">
                 <form:option value="" label="Elija una formulario"/>
                <c:forEach items="${wizardFormController.formulario}" var="item">
                    <form:option value="${item.cformulario}"  label="${item.ssiglas} ${item.dformulario}"/>
                 </c:forEach>
            </form:select>     
    
    <div id="updateme">
       
                <H1>SECCIONES</H1>
            
                    <c:choose>
                        <c:when test="${wizardFormController.secciones!=null && fn:length(wizardFormController.secciones)>0}">

                            <form:select  cssClass="select_field" id="formsSections" path="sectionselected.cseccion">
                                    <form:option value="" label="Elija una seccion"/>
                                    <c:forEach items="${wizardFormController.secciones}" var="item">
                                       <form:option value="${item.cseccion}" label="${item.dseccion}"/>
                                    </c:forEach>
                                </form:select>

                        </c:when>
                        <c:otherwise>  
                            <h4>No hay secciones definidas para este Formulario</h4>
                        </c:otherwise>
                    </c:choose>
                            <br>
                <H1>VERSIONES</H1>
                    <c:choose>
                        <c:when test="${wizardFormController.versiones!=null && fn:length(wizardFormController.versiones)>0}">

                                    <form:select  cssClass="select_field" id="formsVertion" path="versionselected.id.cversion">
                                      <form:option value="" label="Elija una version"/>   
                                     <c:forEach items="${wizardFormController.versiones}" var="item2">
                                        <form:option value="${item2.id.cversion}" label="${item2.id.cversion}"/>
                                     </c:forEach>
                                     </form:select>

                        </c:when>
                        <c:otherwise>  
                                        <h4> No hay versiones para este formulario</h4>
                        </c:otherwise>
                    </c:choose> 
        
    </div>                     
                   
    <input style=" height: 50px" type="button" onclick="SubmitForm()" value="Construir">      
            
    </form:form>    
    
   </fieldset> 
</center>
 